﻿using Max.PH4.Shoppgin.Admin.DataAccess;
using Max.PH4.Shoppgin.Admin.Domain;
using Max.PH4.Shoppgin.Admin.IRespository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.PH4.Shoppgin.Admin.Respository
{
    public class OrderDetailRespository: IOrderDetailRespository
    {
        MyDbContext _context;

        public OrderDetailRespository(MyDbContext context)
        {
            _context = context;
        }

        public void Delete(OrderDetailEntity entity)
        {
            _context.Remove(entity);
        }

        public void Delete(object id)
        {
            var m = _context.OrderDetails.Find(id);
            if (m != null)
                _context.OrderDetails.Remove(m);
        }

        public void Insert(OrderDetailEntity entity)
        {
            _context.OrderDetails.Add(entity);
        }

        public void Insert(List<OrderDetailEntity> entities)
        {
            _context.OrderDetails.AddRange(entities);
        }

        public IQueryable<OrderDetailEntity> Query()
        {
            return _context.OrderDetails;
        }

        public void Update(OrderDetailEntity entity)
        {
            _context.OrderDetails.Update(entity);
        }

        public void Update(List<OrderDetailEntity> entities)
        {
            _context.OrderDetails.UpdateRange(entities);
        }
    }
}
